package cn.sinata.wanglin.utils;

import android.app.Activity;
import com.umeng.socialize.ShareAction;
import com.umeng.socialize.ShareContent;
import com.umeng.socialize.bean.SHARE_MEDIA;
import com.umeng.socialize.media.UMImage;

import cn.sinata.wanglin.R;

/**
 *
 */
public class ShareUtils {

    public static void share(Activity context, String content, String title, String tagUrl){
        final SHARE_MEDIA[] displaylist = new SHARE_MEDIA[]
                {
                        SHARE_MEDIA.WEIXIN, SHARE_MEDIA.WEIXIN_CIRCLE, SHARE_MEDIA.SINA,
                        SHARE_MEDIA.QQ, SHARE_MEDIA.QZONE
                };
        UMImage image = new UMImage(context, R.mipmap.ic_share_icon);
        ShareContent shareContent = new ShareContent();
        shareContent.mMedia = image;
        shareContent.mTitle = title;
        shareContent.mText = content+tagUrl;
        shareContent.mTargetUrl = tagUrl;

        new ShareAction(context).setDisplayList( displaylist ).setShareContent(shareContent)
                .open();
    }

    public static void share(Activity context, String content, String title, String tagUrl, UMImage image){
        final SHARE_MEDIA[] displaylist = new SHARE_MEDIA[]
                {
                        SHARE_MEDIA.WEIXIN, SHARE_MEDIA.WEIXIN_CIRCLE, SHARE_MEDIA.SINA,
                        SHARE_MEDIA.QQ, SHARE_MEDIA.QZONE
                };
        new ShareAction(context).setDisplayList( displaylist )
                .withText( content )
                .withTitle(title)
                .withTargetUrl(tagUrl)
                .withMedia(image)
                .open();
    }
}
